﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.SettlementClaimedLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class SettlementClaimedLogEntry : LogEntry, IChatNotification
  {
    [SaveableField(320)]
    public readonly Hero Claimant;
    [SaveableField(321)]
    public readonly Settlement Settlement;
    [SaveableField(322)]
    private readonly Clan _settlementClan;

    internal static void AutoGeneratedStaticCollectObjectsSettlementClaimedLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.Claimant);
      collectedObjects.Add((object) this.Settlement);
      collectedObjects.Add((object) this._settlementClan);
    }

    internal static object AutoGeneratedGetMemberValueClaimant(object o)
    {
      return (object) ((SettlementClaimedLogEntry) o).Claimant;
    }

    internal static object AutoGeneratedGetMemberValueSettlement(object o)
    {
      return (object) ((SettlementClaimedLogEntry) o).Settlement;
    }

    internal static object AutoGeneratedGetMemberValue_settlementClan(object o)
    {
      return (object) ((SettlementClaimedLogEntry) o)._settlementClan;
    }

    public bool IsVisibleNotification => true;

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(240f);

    public SettlementClaimedLogEntry(Hero claimant, Settlement settlement)
    {
      this.Claimant = claimant;
      this.Settlement = settlement;
      this._settlementClan = settlement.OwnerClan;
    }

    public override string ToString() => this.GetNotificationText().ToString();

    public TextObject GetNotificationText()
    {
      TextObject parent = new TextObject("{=ARNYrXln}{TROOP.NAME} has claimed {SIDE1_PARTY} currently held by the {SIDE2_FACTION}");
      StringHelpers.SetCharacterProperties("TROOP", this.Claimant.CharacterObject, parent);
      parent.SetTextVariable("SIDE1_PARTY", this.Settlement.Name);
      parent.SetTextVariable("SIDE2_FACTION", this._settlementClan.Name);
      return parent;
    }
  }
}
